package com.shop.loan.exception;

import com.shop.loan.model.common.Code;
import com.shop.loan.model.common.ResResult;
import com.shop.loan.util.Util;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@Slf4j
@ControllerAdvice
public class MyExceptionHandler {

    @ExceptionHandler({Exception.class})
    @ResponseBody
    public Object handException(Exception e) {
        log.error(Util.GetErrorDetails(e));
        return new ResResult(Code.FAIL);
    }
}
